/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hva.web.mvcwebapp.models;
import java.util.Date;
 
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
 
@Entity
@Table(name = "page_widget")
@AssociationOverrides({
		@AssociationOverride(name = "pk.page", 
			joinColumns = @JoinColumn(name = "PAGE_ID")),
		@AssociationOverride(name = "pk.widget", 
			joinColumns = @JoinColumn(name = "WIDGET_ID")) })
public class PageWidget implements java.io.Serializable {
 
	private PageWidgetId pk = new PageWidgetId();
	private int locationId;
 
	public PageWidget() {
	}
 
	@EmbeddedId
	public PageWidgetId getPk() {
		return pk;
	}
 
	public void setPk(PageWidgetId pk) {
		this.pk = pk;
	}
 
	@Transient
	public Page getPage() {
		return getPk().getPage();
	}
 
	public void setPage(Page page) {
		getPk().setPage(page);
	}
 
	@Transient
	public Widget getWidget() {
		return getPk().getWidget();
	}
 
	public void setWidget(Widget widget) {
		getPk().setWidget(widget);
	}
 
	@Column(name = "WIDGET_LOCATION", nullable = false, length = 10)
	public int getWidgetLocation() {
		return this.locationId;
	}
 
	public void setWidgetLocation(int widgetLocation) {
		this.locationId = widgetLocation;
	}
 
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
 
		PageWidget that = (PageWidget) o;
 
		if (getPk() != null ? !getPk().equals(that.getPk())
				: that.getPk() != null)
			return false;
 
		return true;
	}
 
	public int hashCode() {
		return (getPk() != null ? getPk().hashCode() : 0);
	}
}